from flask import Flask, render_template
from config import Config

def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)
    
    # Initialize configuration
    Config.init_app(app)
    
    # Register blueprints
    from blueprints.behavior.routes import behavior_bp
    from blueprints.image_text.routes import image_text_bp
    from blueprints.knowledge_graph import knowledge_graph_bp
    
    app.register_blueprint(behavior_bp, url_prefix='/behavior')
    app.register_blueprint(image_text_bp, url_prefix='/image_text')
    app.register_blueprint(knowledge_graph_bp, url_prefix='/knowledge_graph')
    
    # Main route
    @app.route('/')
    def index():
        return render_template('index.html')
    
    return app

if __name__ == '__main__':
    app = create_app()
    app.run(debug=True, host='0.0.0.0', port=5000)